<template>
	<view class="flex_c">
		<view class="flex_r" :class="{ text_box: isMy }">
			<view class="text-box" @tap.stop="onClick">
				<view
					class="text_30 flex_r fa_c text"
					:class="isMy ? 'text_r' : 'text_l'"
					:style="{ width: setWidth }"
					:hover-class="isMy ? 'hover_classr' : 'hover_classl'"
					:hover-stay-time="60"
				>
					<view class="text-icon" v-if="value.pause !== 3">
						<image
							class="img"
							src=""
							mode="aspectFill"
						></image>
					</view>
					<view class="text-icon" v-if="value.pause == 3">
						<image class="img" style="transform: scale(1.35)"  :src="require('../../static/images/play.gif')" mode="aspectFill"></image>
					</view>
					<view class="text-duration">{{ Math.ceil(value.payload.duration) || 1 }}''</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
export default {
	components: {},
	props: {
		isMy: {
			type: [Boolean, Number],
			default: false
		},
		value: {
			type: Object,
			default: {}
		}
	},
	data() {
		return {};
	},
	computed: {
		setWidth() {
			let width = 0;
			const duration = Math.ceil(this.value.payload.duration);
			// 基础长度
			let basis = duration - 10;
			if (basis >= 0) {
				width = 10 * 8 + 60;
				width = width + basis * 2;
			} else {
				width = duration * 8 + 60;
			}
			return `${width}px`;
		}
	},
	methods: {
		onClick() {
			this.$emit('onClick');
		}
	}
};
</script>

<style scoped lang="scss">
.row_ {
	flex-direction: row-reverse;
}
.text_box {
	flex-direction: row-reverse;
}
.text-box {
	border-radius: 8rpx;
}

.text {
	position: relative;
	z-index: 99;
	box-sizing: border-box;
	padding: 18rpx 16rpx;
	border-radius: 8rpx;
	word-break: break-all;
	vertical-align: center;
	.text-icon {
		width: 32rpx;
		height: 32rpx;
		margin: 0 4rpx;
	}
	.text-duration {
		margin: 0 8rpx;
	}
}

.text_r {
	position: relative;
	z-index: 2;
	background-color: #95ec6a;
	flex-direction: row-reverse;
	.text-icon {
		transform: rotate(180deg);
	}
}
.text_l {
	position: relative;
	z-index: 2;
	background-color: #fff;
}

.text_r::after {
	position: absolute;
	z-index: -1;
	content: '';
	top: 28rpx;
	right: -8rpx;
	width: 18rpx;
	height: 18rpx;
	border-radius: 2px;
	transform: rotate(45deg);
	background-color: #95ec6a;
}
.text_l::after {
	position: absolute;
	z-index: -1;
	content: '';
	top: 28rpx;
	left: -8rpx;
	width: 18rpx;
	height: 18rpx;
	border-radius: 2px;
	transform: rotate(45deg);
	background-color: #fff;
}
.hover_classr {
	background-color: #89d961;
}
.hover_classl {
	background-color: #e2e2e2;
}

.hover_classr::after {
	position: absolute;
	z-index: -1;
	content: '';
	top: 28rpx;
	right: -8rpx;
	width: 18rpx;
	height: 18rpx;
	border-radius: 2px;
	transform: rotate(45deg);
	background-color: #89d961;
}
.hover_classl::after {
	position: absolute;
	z-index: -1;
	content: '';
	top: 28rpx;
	left: -8rpx;
	width: 18rpx;
	height: 18rpx;
	border-radius: 2px;
	transform: rotate(45deg);
	background-color: #e2e2e2;
}
</style>
